import ProForm, { ProFormProps } from "@/components/ProForm/index.vue";
import { ComponentPublicInstance, CSSProperties } from "vue";

export interface basicForm {
  options: optionsProps[];
  minWidth?: Number;
  labelWidth?: Array<number>;
  visible: boolean;
  title: string;
  width?: string;
  formCols?: number;
  formAttrs?: FormProps;
  transitionArr?: transitionProp[];
}

export interface customForm<T = any> extends basicForm {
  form: T;
}
export interface optionsProps {
  type: "input" | "select" | "date-picker" | "cascader" | "cascader-panel" | "checkbox";
  label: string;
  prop: string;
  hide: boolean;
  cols?: number;
  defaultValue?: string | number | boolean | any[] | Date;
  attrs?: attrsProps;
  children?: childrenProps[];
  rules?: FormItemRules[];
  changeMethod?: (params?: any) => void;
  inputMethod?: (params?: any) => void;
}

export interface childrenProps {
  label: string;
  value: string | number;
  type?: "option";
  children?: childrenProps[];
}
export interface attrsProps {
  placeholder?: string;
  label?: string;
  value?: string;
  type?: "textarea" | "date" | "number" | "month" | "datetime" | "";
  valueFormat?: string;
  format?: string;
  style?: CSSProperties;
  loading?: boolean;
  clearable?: Boolean;
  disabled?: Boolean;
  multiple?: Boolean;
  filterable?: Boolean;
  showAllLevels?: Boolean;
  options?: childrenProps[];
  remote?: Boolean;
  "reserve-keyword"?: Boolean;
  "remote-method"?: (query: string) => void;
  "value-format"?: string;
}
export interface FormProps {
  labelWidth?: string | number;
  labelPosition?: "left" | "right" | "top";
  inline?: boolean;
}
export interface FormItemRules {
  required?: boolean;
  message?: string;
  validator?: Function;
  trigger: "blur" | "change";
}

export interface transitionProp {
  newField: string;
  oldField: string;
}

export type ProFormInstance = Omit<InstanceType<typeof ProForm>, keyof ComponentPublicInstance | keyof ProFormProps>;
